package cn.hm.common.wx;

import com.github.wxpay.sdk.WXPayUtil;

import java.util.HashMap;
import java.util.Map;

/**
 * 微信SDK相关测试：
 * @author Mxb
 * @version 1.0
 * @date 2020/10/5 16:12
 */
public class WxUtilsTest {

    public static void main(String[] args) throws Exception {
        /**
         * 生成随机字符方法
         */
        String s = WXPayUtil.generateNonceStr();
        System.out.println("随机字符方法:" + s);

        Map<String, String> map = new HashMap<>();

        map.put("id", "1");
        map.put("name", "18");
        map.put("age", "ju233");
        /**
         * map转xml
         */
        String s2 = WXPayUtil.mapToXml(map);
        System.out.println("xml转换成功：" + s2);

        /**
         * xml转map
         */
        Map<String, String> map2 = WXPayUtil.xmlToMap(s2);

        System.out.println(map2);
        /**
         * 将map转为xml，并添加签名
         */

        String sign = "heima";
      String n = WXPayUtil.generateSignedXml(map, sign);
        System.out.println(n);
    }
}
